package com.shardingsphere.shardingsphere.controller;

import com.shardingsphere.shardingsphere.domain.User;
import com.shardingsphere.shardingsphere.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
	@Autowired
	private  UserService userService;

	@GetMapping("/add/{id}")
	public void  savaUser(@PathVariable Integer id){
		User user=new User();
		user.setId(id);
		user.setName("菜菜"+id);
		user.setSex("男");
		userService.save(user);

	}
	@GetMapping("/list")
	public List<User> selectUser(){
		return userService.getUserList();
	}

}
